﻿<%@ Page language="c#" Inherits="Discuz.Web.Admin.adduser" Codebehind="global_adduser.aspx.cs"%>
<%@ Register TagPrefix="cc1" Namespace="Discuz.Control" Assembly="Discuz.Control" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>添加用户</title>				
<script type="text/javascript" src="../js/common.js"></script>	
<link href="../styles/dntmanager.css" type="text/css" rel="stylesheet" />        
<link href="../styles/modelpopup.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/modalpopup.js"></script>	
<script language="JavaScript" type="text/javascript" src="../../javascript/ajax.js"></script>
<script type="text/javascript">
function IsValidPost()
{
    var admingroup="";
    var groupid = document.getElementById("groupid");		
    if((groupid.value=="1")||(groupid.value=="2")||(groupid.value=="3"))  {
     admingroup=groupid.options[groupid.value].innerHTML;
    }
    if(groupid.value=="0")
    {   
     alert('您未选择所属用户组');
     return false;
    } 
    if(admingroup!=""){
    if(confirm('您是要添加 "'+admingroup+'" 组的用户吗?'))
    {
       return true;
    }
    else
    {
       return false;
    }	
    }
    return true;
    }

    function GetUserInfo() {
            var usercode =$('userName').value;
            _sendRequest("../../../services/getTYUserJSON.aspx", getuser_callback, false, 'userCode='+usercode);
    }
    function getuser_callback(result){
        if(result=="0"){
            alert("在调用WebService时发生错误，获取数据失败");
            return;
        }
        var aData = eval('('+result+')');
        if(aData){
           if(aData.userName!=undefined){
            $('TYUserName').value = aData.userName;
            }
            else{
                alert('该用户不存在，请重新输入');
            }            
        }
        else{
            alert('该用户不存在，请重新输入');
        }
    }
    function TYCorpDropBind(result){
        if(result=="0"){
            alert("在调用WebService时发生错误，获取数据失败");
            return;
        }
        var aData = eval('('+result+')');
        var s = document.getElementById('Corpid');
        SelectBind(s,aData);
    }
    function TYDeptDropBind(result){
        if(result=="0"){
            alert("在调用WebService时发生错误，获取数据失败");
            return;
        }
        var aData = eval('('+result+')');
        var s = document.getElementById('Deptid');
        SelectBind(s,aData);
    }
    function SelectBind(s,aData){
        for(i=0;i<aData.length;i++){
           var option = document.createElement("option");
           option.appendChild(document.createTextNode(aData[i].name));
           option.value = aData[i].id;
           s.appendChild(option);          
        }
    }    
    var corp = '<%=Corpid.ClientID %>';
    var dept = '<%=Deptid.ClientID %>';
    var deptName = '<%=deptNameHidden.ClientID %>';
    var deptId = '<%=deptIdHidden.ClientID %>';
    var corpName = '<%=corpNameHidden.ClientID %>';
    var corpId = '<%=corpIdHidden.ClientID %>';
   function OnCorpSelected(){
       var s = document.getElementById(corp);
       var name = document.getElementById(corpName);
       var id = document.getElementById(corpId);
       id.value = s.value;
       name.value = s.options[s.selectedIndex].text;
   }
   function OnDeptSelected(){
       var s = document.getElementById(dept);
       var name = document.getElementById(deptName);
       var id = document.getElementById(deptId);
       id.value = s.value;
       name.value = s.options[s.selectedIndex].text;
   }
    
    window.onload = function(){
        var usercode = '<%=m_LoginUser_TYUserCode %>';
         _sendRequest("../../../services/getBoCorpJSON.aspx?User="+usercode+"&i="+Math.random(), TYCorpDropBind, false, '');
         _sendRequest("../../../services/getBoDeptJSON.aspx?User="+usercode+"&i="+Math.random(), TYDeptDropBind, false, '');
    }
</script>		
<meta http-equiv="X-UA-Compatible" content="IE=7" />
</head>
<body>

<div class="ManagerForm">
<form id="Form1" method="post" runat="server">
<fieldset>
<legend style="background:url(../images/icons/icon9.jpg) no-repeat 6px 50%;">添加用户</legend>
<table width="100%">	
    <tr><td class="item_title">会员归属公司</td><td class="item_title">会员归属部门</td></tr>
    <tr>
		<td class="vtop rowform">
			<cc1:DropDownList id="Corpid" runat="server" IsMustBeSelected="true" width="220px"></cc1:DropDownList>
			<asp:RequiredFieldValidator ID="rfvCorpid" runat="server" ErrorMessage="必选" ControlToValidate="Corpid" InitialValue="0">*</asp:RequiredFieldValidator>
			<asp:HiddenField ID="corpIdHidden" runat="server" />
			<asp:HiddenField ID="corpNameHidden" runat="server" />
		</td>
		<td class="vtop rowform">
			<cc1:DropDownList id="Deptid" runat="server"  width="220px"></cc1:DropDownList>
			<asp:RequiredFieldValidator ID="rfvDeptid" runat="server" ErrorMessage="必选" ControlToValidate="Deptid" InitialValue="0">*</asp:RequiredFieldValidator>
			<asp:HiddenField ID="deptIdHidden" runat="server" />
			<asp:HiddenField ID="deptNameHidden" runat="server" />
		</td>
	</tr>
	<tr><td class="item_title">会员姓名</td></tr>
	<tr>
		<td class="vtop rowform">
			<cc1:textbox id="TYUserName" runat="server" CanBeNull="必填" RequiredFieldType="暂无校验"  MaxLength="20" Size="30"></cc1:textbox>
		</td>
	</tr>	
	<tr><td class="item_title" colspan="2">会员工号</td></tr>
	<tr>	
	    <td>	
			 <cc1:textbox id="userName"  runat="server" CanBeNull="必填" RequiredFieldType="暂无校验"  MaxLength="20" Size="30"></cc1:textbox>			 
		</td>
		<td class="vtop"></td>
	</tr>
	<tr>
	    <td colspan="2">
	        <input type="button" id="TYUserBtn" name="TYUserBtn" value="确定" onclick="javascript:GetUserInfo();" />
	    </td>
	</tr>
	<tr><td class="item_title" colspan="2">密码</td></tr>
	<tr>
		<td class="vtop rowform">
			<cc1:TextBox ID="password" runat="server" CanBeNull="必填" MaxLength="32" RequiredFieldType="暂无校验" Size="30"></cc1:TextBox>
		</td>
		<td class="vtop"></td>
	</tr>
	<tr><td class="item_title">移动电话号码</td><td class="item_title">固定电话号码</td></tr>
	<tr>
		<td class="vtop rowform">
			<cc1:textbox id="mobile" runat="server" MaxLength="20" Size="20"></cc1:textbox>
		</td>
		<td class="vtop rowform">
			<cc1:textbox id="phone" runat="server" CanBeNull="可为空" MaxLength="20" Size="20"></cc1:textbox>
		</td>
	</tr>
	<tr style="display:none"><td class="item_title" colspan="2">E-mail</td></tr>
	<tr style="display:none">
		<td class="vtop rowform" colspan="2">
			<cc1:textbox id="email" runat="server" CanBeNull="可为空" RequiredFieldType="电子邮箱"  Width="200" MaxLength="50" Size="60"></cc1:textbox>&nbsp;&nbsp;<input id="sendemail" type="checkbox" runat="server"  />发送邮件到上述邮箱中
		</td>
	</tr>
	<tr><td class="item_title">所属用户组</td><td class="item_title">积分设置</td></tr>
    <tr>
		<td class="vtop rowform">
			<cc1:DropDownList id="groupid" runat="server"></cc1:DropDownList>
		</td>
		<td class="vtop rowform">
			<cc1:textbox id="credits" runat="server" CanBeNull="必填" RequiredFieldType="数据校验" MaxLength="8" Size="10"></cc1:textbox>设置用户的初始积分
		</td>
	</tr>
</table>

<cc1:Hint id="Hint1" runat="server" HintImageUrl="../images"></cc1:Hint>
<div class="Navbutton">
	<cc1:Button id="AddUserInfo" runat="server" Text=" 提 交 "></cc1:Button>
</div>
</fieldset>
</form>
</div>
<%=footer%>
</body>
</html>